//
//  UIUtils.swift
//  icar
//
//  Created by gongkai on 15/4/2.
//  Copyright (c) 2015年 anytracking. All rights reserved.
//

import Foundation

class UIUtils {
    
    /**
    返回当前显示的ViewController
    如为UINavigationController则返回topViewController,否则直接返回
    **/
    class func currentViewController()->UIViewController?{
        let ctr = UIApplication.sharedApplication().keyWindow?.rootViewController
        if let navCtr = (ctr as? UINavigationController){
            return navCtr.topViewController
        }else{
            return ctr
        }
    }
    
    class func setRootViewController(rootViewController:UIViewController){
        UIApplication.sharedApplication().keyWindow?.rootViewController = rootViewController
    }
    
}